#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e5+1000;
typedef long long LL;
typedef pair<LL,LL>P;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
map<P,bool>map1;
int main(void){
    int n;n=read();
    for(int i=1;i<=n;i++)
    {
        int x,y;x=read();y=read();
        map1[{x,y}]=true;
    }
    auto it1=map1.begin();
    LL ans=0;
    for(it1;it1!=map1.end();it1++)
    {

        for(auto it2=next(it1);it2!=map1.end();it2++)
        {
            P L =(*it1).first;
            P R =(*it2).first;
            if (L.first == R.first || L.second == R.second) continue;
            if (!map1.count(L)) continue;
            if (!map1.count(R)) continue;
            if ( map1.count({L.first, R.second}) && map1.count({R.first, L.second}))
            {
                ans++;
            }
        }
    }
    printf("%lld\n",ans/2);
   	return 0;
}
